package edu.scau.hot.service.impl;

import edu.scau.hot.entity.HotType;
import edu.scau.hot.mapper.HotTypeMapper;
import edu.scau.hot.service.IHotTypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HotType)表服务实现类
 *
 * @author PaperEasyCode
 * @since 2022-02-28 21:55:10
 */
@Service("hotTypeService")
public class HotTypeServiceImpl implements IHotTypeService{
    @Resource
    private HotTypeMapper hotTypeMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param typeId 主键
     * @return 实例对象
     */
    @Override
    public HotType queryById(Integer typeId) {
        return this.hotTypeMapper.queryById(typeId);
    }

    /**
     * 查询所有数据
     *
     * @param hotType 筛选条件
     * @return 查询结果
     */
    @Override
    public List<HotType> queryAll(HotType hotType) {
        return this.hotTypeMapper.queryAll(hotType);
    }

    /**
     * 新增数据
     *
     * @param hotType 实例对象
     * @return 实例对象
     */
    @Override
    public HotType insert(HotType hotType) {
        this.hotTypeMapper.insert(hotType);
        return hotType;
    }

    /**
     * 修改数据
     *
     * @param hotType 实例对象
     * @return 实例对象
     */
    @Override
    public HotType update(HotType hotType) {
        this.hotTypeMapper.update(hotType);
        return this.queryById(hotType.getTypeId());
    }

    /**
     * 通过主键删除数据
     *
     * @param typeId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer typeId) {
        return this.hotTypeMapper.deleteById(typeId) > 0;
    }
}
